from app.services.business.gaolu_diagnose.ind.abstract_ind import AbstractInd


class  CG_LT_GL_GL04_LDWDBTE1133_B_Zhong6693(AbstractInd):

    def get_name(self):
        return  "CG_LT_GL_GL04_LDWDBTE1133_B_Zhong6693"

    def get_sql(self, params):

        sql = """
        SELECT  mean(value)   AS  CG_LT_GL_GL04_LDWDBTE1133_B_Zhong6693  FROM "CG"  WHERE code='CG_LT_GL_GL04_LDWDBG6200TE1133'     
        and time > '{dt_start_tz}' and time < '{dt_end_tz}'
        """.format(**params)

        return sql

    @AbstractInd.cache_wrapper
    def get_result(self):
        sql = self.get_sql(self.params)
        client = self.influx_client

        result_set = list(client.query(sql))
        value = self.get_influx_result(result_set, "CG_LT_GL_GL04_LDWDBTE1133_B_Zhong6693")

        return value